/*
 * @Author       : 震雨 LuckRain7
 * @Date         : 2020-11-24 22:25:36
 * @LastEditTime : 2020-11-25 11:20:45
 * @Description  : jsx 渲染组件
 * @ 0 Error 0 Warning 0 Bug | Love and Peace
 */

export default {
  props: ['renderJson', 'render_config'],
  methods: {
    createTemplateCode() {
      const { children } = this.render_config;

      let formItem = []; // 生成表单内模块

      function formItemtemplate(_item) {
        const Tag = _item.tag
        return (
          <a-form-model-item label={_item.label}>
            <Tag ></Tag>
          </a-form-model-item>
        );
      }

      children.forEach((item) => {
        formItem.push(formItemtemplate(item));
      });

      let form = (
        <a-form-model layout='horizontal' label-col={{ span: 4 }} wrapper-col={{ span: 14 }}>
          {formItem.map(item => {
            return item
          })}
        </a-form-model>
      )
        ;

      return form;
    },

  },
  render: function (h) {
    return this.createTemplateCode()
  },
}
